package com.sbpm.crmbpm.client.forms.controls;

import com.google.gwt.core.client.GWT;
import com.sbpm.crmbpm.shared.data.client.Segment;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
import com.sencha.gxt.widget.core.client.form.ComboBox;

import java.util.Arrays;

public class SegmentComboBox extends ComboBox<Segment>
{

    interface SegmentProperties extends PropertyAccess<Segment>
    {
        ModelKeyProvider<Segment> value();

        LabelProvider<Segment> label();
    }

    private static SegmentProperties segmentProperties = GWT.create( SegmentProperties.class );

    private static ListStore< Segment > segmentListStore = new ListStore< Segment >( segmentProperties.value() );
    static
    {
        segmentListStore.addAll( Arrays.asList( Segment.values() ) );
    }

    public SegmentComboBox()
    {
        super( segmentListStore, segmentProperties.label() );
        setTypeAhead( true );
        setTriggerAction( ComboBoxCell.TriggerAction.ALL );
    }


}
